<%--
  Created by IntelliJ IDEA.
  User: 帅龙
  Date: 2020/12/3
  Time: 11:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%pageContext.setAttribute("APP_PATH", request.getContextPath());%>
<html>
<head>
    <title>设备报修</title>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="${APP_PATH }/recourse/css/font.css">
    <link rel="stylesheet" href="${APP_PATH}/recourse/css/login.css">
    <link rel="stylesheet" href="${APP_PATH }/recourse/css/xadmin.css">
    <script src="${APP_PATH }/assets/js/jquery-2.1.4.min.js"></script>
    <script src="${APP_PATH }/recourse/js/jquery-form.js"></script>
</head>
<body>
<form id="repair" name = "repair" action="${pageContext.request.contextPath}/approver/repair" method="post" enctype="multipart/form-data">
<div class="layui-fluid">
    <div class="layui-row">
        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                <span class="x-red">*</span>报修名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="name" name="name" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>报修名称的输入请尽量简洁
            </div>
        </div>
        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                <span class="x-red">*</span>有效天数
            </label>
            <div class="layui-input-inline">
                <input type="text" id="time" name="time" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" value="0">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>报修有效天数为默认无期限
            </div>
        </div>
        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                <span class="x-red">*</span>维修地点
            </label>
            <div class="layui-input-inline">
                <input type="text" id="localtion" name="localtion" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>维修地点为必填项
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>问题描述</label>
            <div class="layui-input-inline" style="width: 320px">
                <textarea id="problem_words" name="problem_words" placeholder="请输入内容" class="layui-textarea" ></textarea>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>问题描述很对维修人员很重要
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>维修要求</label>
            <div class="layui-input-inline" style="width: 320px">
                <textarea id="requests" name="requests" placeholder="请输入内容" class="layui-textarea" ></textarea>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>维修要求非必填项
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>图片上传</label>
            <div class="layui-input-inline" style="width: 320px">
                <input type="file"  name="photos" id="photos"  class="selectedLogoImgId"
                       accept="image/jpg,image/jpeg,image/png,image/bmp" style="margin-top: 8px;" multiple/>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>故障图片非为必填项
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>视频上传</label>
            <div class="layui-input-inline" style="width: 320px">
                <input type="file"  name="videos" id="videos"  class="selectedLogoImgId" accept="audio/mp4, video/mp4" style="margin-top: 8px;" multiple/>
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>故障视频非必填项
            </div>
        </div>
        <input id="add" type="submit" class="layui-btn" style="height: 40px;width:110px;margin-left: 300px;margin-top: 15px;" value="提交" onclick="ko()"/>
    </div>
</div>
</form>
<script type="text/javascript">
    function ko(){
        var day = document.getElementById("time");
        if(!/^[0-9]*[1-9][0-9]*$/.test(day.value)) {
            alert("竞单时间输入格式不正确！");
            day.focus();
            day.select();
            return false;
        }
    }
     $(document).ready(function () {
         $('#repair').ajaxForm(function (data) {
             if(data === 0){
                     alert("提交成功!");
                     setTimeout(function (){
                         // 这里就是处理的事件
                         window.close();
                         window.opener.location.reload();
                     }, 400);
                 }else if(data===-5){
                        alert("没有审核员可审核，请及时添加审核员!");
                 setTimeout(function (){
                     // 这里就是处理的事件
                     window.close();
                     window.opener.location.reload();
                 }, 400);
                 }else{
                        alert("提交失败!");
             }
         });
 });
</script>
</body>
</html>
